﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Text;

namespace paper.evisa99.com.Controllers.Class
{
    public class Html
    {
        //====================================================================
        /// <summary>
        /// 段落开始
        /// </summary>
        /// <param name="GroupID">给段落设置id，形如Group_GroupID，用于控制段落显示</param>
        /// <param name="IsDisplay">是否显示</param>
        /// <returns></returns>
        public string GroupStart(string GroupID = "", bool IsDisplay = true)
        {
            if (GroupID != "") { GroupID = " id=\"Group_" + GroupID + "\""; }
            string Style = "";
            if (!IsDisplay) { Style = " style=\"display:block;background-color:#f3f3f3;\""; }
            return "<ul class=\"ContentRow\"" + GroupID + Style + ">";
        }
        //--------------------------------------------------------------------------------------------
        public string GroupEnd()
        {
            return "</ul><div style=\"clear:both;\">&nbsp;</div>";
        }
        //--------------------------------------------------------------------------------------------
        public string HelpCell(string HelpText = "")
        {
            if (HelpText == "") { HelpText = "<span class=\"title\">&nbsp;</span>"; } else { HelpText = "<div>" + HelpText + "</div>"; }
            string txt = "<li><span class=\"title\">&nbsp;</span>" + HelpText + "</li>";
            return txt;
        }
        //====================================================================
        public string EmptyBlank()
        {
            string txt = "<li><span class=\"title\">&nbsp;</span><span class=\"title\">&nbsp;</span></li>";
            return txt;
        }
        //====================================================================
        public string TextCaution(string text)
        {
            string txt = "<li style=\"width:710px;height:auto;\"><div class=\"caution\">" + text + "</div></li>";
            return txt;
        }
        //====================================================================
        /// <summary>
        /// 文本框
        /// </summary>
        /// <param name="info">ref DataTable</param>
        /// <param name="GroupFlag">会给控件加一个形如DataFieldName_X的尾标</param>
        /// <param name="Title">标题</param>
        /// <param name="DataFieldName">数据库对应的字段名</param>
        /// <param name="PlaceHolder">内部说明</param>
        /// <param name="MaxLength">字符限制</param>
        /// <param name="ValidType">填写校验类型：普通（Fill），中文（CN），拼音（PY），英文（EN），数字（NUM），邮箱（Email），手机（Mobile）</param>
        /// <param name="ValidParent">父控件HtmlID</param>
        /// <param name="ValidParentDecide">父控件验证条件的值</param>
        /// <param name="IsLongCtl">是否长文本框</param>
        /// <returns></returns>
        public string TextBox(ref DataTable info, string GroupFlag, string Title, string DataFieldName, string PlaceHolder, int MaxLength,
            string ValidType, string ValidParent, string ValidParentDecide, bool IsLongCtl, bool IsRequired)
        {
            StringBuilder ctl = new StringBuilder();
            string style = "";
            if (IsLongCtl) { style += "width:470px;"; }
            if (style != "") { style = " style=\"" + style + "\""; }
            ctl.AppendLine("<li" + style + ">");
            ctl.AppendLine("<span class=\"title\">" + Title + "</span>");
            if (IsRequired)
            {
                ctl.AppendLine("<span id=\"lbl" + DataFieldName + "\" class=\"tip\">*</span>");
            } else
            {
                ctl.AppendLine("<span id=\"lbl" + DataFieldName + "\" class=\"tip\">&nbsp;</span>");
            }
            ctl.AppendLine("<input type=\"text\" class=\"form-control\" id=\"txt" + DataFieldName + GroupFlag + "\" name=\"txt" + DataFieldName + GroupFlag
                + "\" placeholder=\"" + PlaceHolder + "\" maxlength=\"" + MaxLength.ToString()
                + "\" data-tip=\"" + Title + "\" data-parent=\"" + ValidParent + "\" data-decide=\"" + ValidParentDecide + "\" data-type=\"" + ValidType
                + "\" />");
            ctl.AppendLine("</li>");
            return ctl.ToString();
        }
        //--------------------------------------------------------------------------------------------
        public string DateYMD(ref DataTable info, string GroupFlag, string Title, string DataFieldName, string DefaultTime, string StartTime, string EndTime,
             string ValidParent, string ValidParentDecide, bool IsLongCtl, bool IsRequired)
        {
            StringBuilder ctl = new StringBuilder();
            string style = "";
            if (IsLongCtl) { style += "width:470px;"; }
            if (style != "") { style = " style=\"" + style + "\""; }
            ctl.AppendLine("<li" + style + ">");
            ctl.AppendLine("<span class=\"title\">" + Title + "</span>");
            if (IsRequired)
            {
                ctl.AppendLine("<span id=\"lbl" + DataFieldName + "\" class=\"tip\">*</span>");
            } else
            {
                ctl.AppendLine("<span id=\"lbl" + DataFieldName + "\" class=\"tip\">&nbsp;</span>");
            }
            ctl.AppendLine("<input type=\"text\" class=\"form-control ct_date\" id=\"txt" + DataFieldName + GroupFlag + "\" name=\"txt" + DataFieldName + GroupFlag
                + "\" data-tip=\"" + Title + "\" data-parent=\"" + ValidParent + "\" data-decide=\"" + ValidParentDecide
                + "\" readonly=\"readonly\" onfocus=\"modalDateYMD('txt" + DataFieldName + GroupFlag + "','" + Title + "','" + DefaultTime + "','" + StartTime + "','" + EndTime + "');\" />");
            ctl.AppendLine("</li>");
            return ctl.ToString();
        }
        public string DateYM(ref DataTable info, string GroupFlag, string Title, string DataFieldName, string DefaultTime, string StartTime, string EndTime,
            string ValidParent, string ValidParentDecide, bool IsLongCtl, bool IsRequired)
        {
            StringBuilder ctl = new StringBuilder();
            string style = "";
            if (IsLongCtl) { style += "width:470px;"; }
            if (style != "") { style = " style=\"" + style + "\""; }
            ctl.AppendLine("<li" + style + ">");
            ctl.AppendLine("<span class=\"title\">" + Title + "</span>");
            if (IsRequired)
            {
                ctl.AppendLine("<span id=\"lbl" + DataFieldName + "\" class=\"tip\">*</span>");
            } else
            {
                ctl.AppendLine("<span id=\"lbl" + DataFieldName + "\" class=\"tip\">&nbsp;</span>");
            }
            ctl.AppendLine("<input type=\"text\" class=\"form-control ct_date\" id=\"txt" + DataFieldName + GroupFlag + "\" name=\"txt" + DataFieldName + GroupFlag
                + "\" data-tip=\"" + Title + "\" data-parent=\"" + ValidParent + "\" data-decide=\"" + ValidParentDecide
                + "\" readonly=\"readonly\" onfocus=\"modalDateYM('txt" + DataFieldName + GroupFlag + "','" + Title + "','" + DefaultTime + "','" + StartTime + "','" + EndTime + "');\" />");
            ctl.AppendLine("</li>");
            return ctl.ToString();
        }
        //--------------------------------------------------------------------------------------------
        public string Number(ref DataTable info, string GroupFlag, string Title, string DataFieldName, string DefaultNum, string StartNum, string EndNum,
            string ValidParent, string ValidParentDecide, bool IsLongCtl, bool IsRequired)
        {
            StringBuilder ctl = new StringBuilder();
            string style = "";
            if (IsLongCtl) { style += "width:470px;"; }
            if (style != "") { style = " style=\"" + style + "\""; }
            ctl.AppendLine("<li" + style + ">");
            ctl.AppendLine("<span class=\"title\">" + Title + "</span>");
            if (IsRequired)
            {
                ctl.AppendLine("<span id=\"lbl" + DataFieldName + "\" class=\"tip\">*</span>");
            } else
            {
                ctl.AppendLine("<span id=\"lbl" + DataFieldName + "\" class=\"tip\">&nbsp;</span>");
            }
            ctl.AppendLine("<input type=\"text\" class=\"form-control ct_date\" id=\"txt" + DataFieldName + GroupFlag + "\" name=\"txt" + DataFieldName + GroupFlag
                + "\" data-tip=\"" + Title + "\" data-parent=\"" + ValidParent + "\" data-decide=\"" + ValidParentDecide
                + "\" readonly=\"readonly\" onfocus=\"modalNumber('txt" + DataFieldName + GroupFlag + "','" + Title + "','" + DefaultNum + "','" + StartNum + "','" + EndNum + "');\" />");
            ctl.AppendLine("</li>");
            return ctl.ToString();
        }
        //--------------------------------------------------------------------------------------------
        public string ChinaCity(string GroupFlag, string Title, string DataFieldName, string ReturnDataFields, string IsChinaOnly,
            string ValidParent, string ValidParentDecide, bool IsLongCtl, bool IsRequired)
        {
            StringBuilder ctl = new StringBuilder();
            string style = "";
            if (IsLongCtl) { style += "width:470px;"; }
            if (style != "") { style = " style=\"" + style + "\""; }
            ctl.AppendLine("<li" + style + ">");
            ctl.AppendLine("<span class=\"title\">" + Title + "</span>");
            if (IsRequired)
            {
                ctl.AppendLine("<span id=\"lbl" + DataFieldName + "\" class=\"tip\">*</span>");
            } else
            {
                ctl.AppendLine("<span id=\"lbl" + DataFieldName + "\" class=\"tip\">&nbsp;</span>");
            }
            ctl.AppendLine("<input type=\"text\" class=\"form-control ct_pick\" id=\"txt" + DataFieldName + GroupFlag + "\" name=\"txt" + DataFieldName + GroupFlag
                + "\" data-tip=\"" + Title + "\" data-parent=\"" + ValidParent + "\" data-decide=\"" + ValidParentDecide
                + "\" readonly=\"readonly\" onfocus=\"modalChinaCity('" + ReturnDataFields + "','" + IsChinaOnly + "');\" />");
            ctl.AppendLine("</li>");
            return ctl.ToString();
        }
        //--------------------------------------------------------------------------------------------
        public string WorkDuty(string GroupFlag, string Title, string DataFieldName,
             string ValidParent, string ValidParentDecide, bool IsRequired)
        {
            StringBuilder ctl = new StringBuilder();
            ctl.AppendLine("<li>");
            ctl.AppendLine("<span class=\"title\">" + Title + "</span>");
            if (IsRequired)
            {
                ctl.AppendLine("<span id=\"lbl" + DataFieldName + "\" class=\"tip\">*</span>");
            } else
            {
                ctl.AppendLine("<span id=\"lbl" + DataFieldName + "\" class=\"tip\">&nbsp;</span>");
            }
            ctl.AppendLine("<input type=\"text\" class=\"form-control ct_pick\" id=\"txt" + DataFieldName + GroupFlag + "\" name=\"txt" + DataFieldName + GroupFlag
                + "\" data-tip=\"" + Title + "\" data-parent=\"" + ValidParent + "\" data-decide=\"" + ValidParentDecide
                + "\" readonly=\"readonly\" onfocus=\"modalWorkDuty('" + DataFieldName + GroupFlag + "');\" />");
            ctl.AppendLine("</li>");
            return ctl.ToString();
        }
        //--------------------------------------------------------------------------------------------
        public string DropDownList(ref DataTable info, string GroupFlag, string Title, string DataFieldName, string ItemList,
            string ValidParent, string ValidParentDecide, bool IsLongCtl, bool IsRequired)
        {
            StringBuilder ctl = new StringBuilder();
            string[] Item = ItemList.Split(',');
            string style = "";
            if (IsLongCtl) { style += "width:470px;"; }
            if (style != "") { style = " style=\"" + style + "\""; }
            ctl.AppendLine("<li" + style + ">");
            ctl.AppendLine("<span class=\"title\">" + Title + "</span>");
            if (IsRequired)
            {
                ctl.AppendLine("<span id=\"lbl" + DataFieldName + "\" class=\"tip\">*</span>");
            } else
            {
                ctl.AppendLine("<span id=\"lbl" + DataFieldName + "\" class=\"tip\">&nbsp;</span>");
            }
            ctl.AppendLine("<select class=\"form-control\" id=\"txt" + DataFieldName + GroupFlag + "\" name=\"txt" + DataFieldName + GroupFlag
                + "\">");
            ctl.AppendLine("<option value=\"\"></option>");
            for (var i = 0; i < Item.Length; i++)
            {
                ctl.AppendLine("<option value=\"" + Item[i] + "\">" + Item[i] + "</option>");
            }
            ctl.AppendLine("</select>");
            ctl.AppendLine("</li>");
            return ctl.ToString();
        }
        //--------------------------------------------------------------------------------------------
        public string JudgeList(ref DataTable info, string GroupFlag, string Title, string DataFieldName, string ItemList, string ScriptFunctionName,
            string ValidParent, string ValidParentDecide, bool IsRequired)
        {
            StringBuilder ctl = new StringBuilder();
            string[] Item = ItemList.Split(',');
            ctl.AppendLine("<li style=\"width:470px;\">");
            ctl.AppendLine("<span class=\"title\">" + Title + "</span>");
            if (IsRequired)
            {
                ctl.AppendLine("<span id=\"lbl" + DataFieldName + "\" class=\"tip\">*</span>");
            } else
            {
                ctl.AppendLine("<span id=\"lbl" + DataFieldName + "\" class=\"tip\">&nbsp;</span>");
            }
            ctl.AppendLine("<select class=\"form-control\" id=\"txt" + DataFieldName + GroupFlag + "\" name=\"txt" + DataFieldName + GroupFlag
                + "\" onchange=\"" + ScriptFunctionName + "(this.value);\" style=\"width:230px;\">");
            ctl.AppendLine("<option value=\"\"></option>");
            for (var i = 0; i < Item.Length; i++)
            {
                ctl.AppendLine("<option value=\"" + Item[i] + "\">" + Item[i] + "</option>");
            }
            ctl.AppendLine("</select>");
            ctl.AppendLine("</li>");
            return ctl.ToString();
        }
        //====================================================================
    }
}